package ch09;

import java.util.Scanner;
import java.io.File;

class _39_ScannerEx2 {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(new File("c:/save/data39.txt"));
		int sum = 0;
		int cnt = 0;

		while (sc.hasNextInt()) {
			sum += sc.nextInt();
			cnt++;
		}

		System.out.println("sum=" + sum);
		System.out.println("average=" + (double) sum / cnt);
	}
}
/*
[data39.txt]
100
200
300
--
sum=600
average=200.0
*/